#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e6 + 5;

int n, m;
string p;
int Next[N];
int dp[N];
void build_next() {
  int t = -1, i = 0;
  Next[0] = -1;
  while (i < n) {
    if (t < 0 || p[i] == p[t]) {
      i++, t++;
      Next[i] = t;
    } else {
      t = Next[t];
    }
  }
}
void solve() {
  static int id = 0;
  ++id;
  cout << "Test case #" << id << endl;
  cin >> p;
  build_next();
  rep(i, 1, n) {
    int j = Next[i];
    int d = i - j;
    if (dp[j] && d % dp[j] == 0 && i % d == 0 || d == j)
      dp[i] = d;
    else
      dp[i] = 0;
    if (dp[i]) cout << i << ' ' << i / dp[i] << endl;
  }
  cout << endl;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while ((cin >> n) && n) solve();
  return 0;
}